package com.ruoyi.rtsp.util;


import org.apache.commons.lang3.ObjectUtils;

import java.util.HashMap;

/**
 * 返回信息
 */
public class AjaxResult extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;
 
    //状态码
    public static final String CODE = "code";
 
    //返回信息
    public static final String MSG = "msg";
 
    //数据
    public static final String DATA = "data";
 
    /**
     * 状态类型
     */
    public enum Type {
        SUCCESS(200),
        ERROR(500);
        private final int value;
        Type(int value) {
            this.value = value;
        }
        public int value() {
            return this.value;
        }
    }
 
    public AjaxResult(Type type, String msg, Object data) {
        super.put(CODE, type.value);
        super.put(MSG, msg);
        if (ObjectUtils.isNotEmpty(data)) {
            super.put(DATA, data);
        }
    }

}